<?php

namespace common\models\wechat;

use Yii;
/**
 * This is the model class for table "wechat_images_reply".
 *
 * @property string $id
 * @property string $rid
 * @property string $title
 * @property string $description
 * @property string $mediaid
 * @property integer $createtime
 */
class WechatImagesReply extends \yii\db\ActiveRecord
{
    public $file;

    //主要用于日志记录
    public $uselog = [
        'tabcomment' => '图片回复',      //用于修改了什么的显示
        'mainfield' => 'title',      //主要的显示标题的字段
        'picturefield' => ['file'],        //图片字段
        'timefield' => [],       //时间字段
        'unsetfiled' =>[],      //不需要记录的字段
    ];


    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'wechat_images_reply';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['rid', 'title', 'description', 'mediaid'], 'required'],
            [['rid', 'createtime'], 'integer'],
            [['title'], 'string', 'max' => 50],
            [['description', 'mediaid'], 'string', 'max' => 255],
            ['file', 'image', 'extensions' => 'jpg, jpeg, gif, png', 'on' => ['insert', 'update']],
            [['createtime'],'safe']
        ];
    }


    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'rule' => '规则名称',
            'title' => '图片标题',
            'description' => '图片简介',
            'keyword' => '关键字',
            'file' => '回复图片'
        ];
    }

    public function getRule()
    {
        return $this->hasOne(WechatReplyRule::className(),['id'=>'rid']);
    }


    public function getKeyword()
    {
        return $this->hasOne(WechatReplyKeyword::className(),['rid'=>'rid']);
    }
}
